package com.yefcion.andcode;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author: yefcion.github.io
 */
public class SecondActivity extends BasicActivity {

    @BindView(R.id.sec_btn_send)
    Button mSecBtnSend;
    @BindView(R.id.sec_btn_back)
    Button mSecBtnBack;
    @BindView(R.id.sec_btn_browser)
    Button mSecBtnBrowser;

    public static void start(Context context) {
        Intent starter = new Intent(context, SecondActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.sec_btn_send, R.id.sec_btn_back, R.id.sec_btn_browser})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.sec_btn_send:
                Toast.makeText(SecondActivity.this, "send", Toast.LENGTH_SHORT).show();

                break;
            case R.id.sec_btn_back:
                finish();
                break;
            case R.id.sec_btn_browser:
                browser();
                break;
            default:
        }
    }

    private void browser() {
        Intent intent = new Intent(Intent.ACTION_VIEW);
//                切记：这里要加 https
        intent.setData(Uri.parse("https://yefcion.github.io"));
        startActivity(intent);
    }
}
